class Post < ActiveRecord::Base
  include HeaderTools
    
	belongs_to :user
	belongs_to :category
	
	validates_presence_of :title, :content
	
	define_index do
  	indexes :title, :as=>:name
  	indexes :content, :as=>:content
  end
	
	def to_param
		"#{self.id}-#{self.slug}"
	end
	
	def before_save
		self.slug = title.dirify
	end
end
